package com.zixi.ai.framework.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.NoRepositoryBean;

import java.util.List;
import java.util.Map;

/**
 * @author mqiqe
 */
@NoRepositoryBean
public interface BaseRepository<T, ID> extends JpaRepository<T, ID>, JpaSpecificationExecutor<T> {
    <M> Page<M> findPage(String sql, Class<M> cls, Pageable pageable);

    Page<T> findAll(Specification<T> spec, Pageable pageable, Sort sort);

    List<T> findAll(String hql, Object... params);

    <M> List<M> findAllM(String hql, Object... params);

    Page<T> findPage(String hql, Pageable pageable);

    Page<T> findPage(String hql, Pageable pageable, Object... params);

    <M> List<M> findAll(String sql, Class<M> cls);

    <M> List<M> findAll(String sql, Class<M> cls, Object... params);

    List<Map<String, Object>> findAllMap(String sql, Object... params);

    <M> M findOne(String sql, Class<M> cls);

    long excute(String sql);
}
